let { db } = require('../tools');

module.exports = (req, res) => {
    let { value, coll } = req.query;
    // console.log(value);
    let condition = {};
    if(value[0]){
        condition.name = new RegExp(value[0], 'i');
    }
    if(value[1]) {
        condition.code = new RegExp(value[1], 'i');
    }
        db.collection(coll)
            .findMany(condition)
                .then(data => {
                    if(data) {
                        res.json(data)
                    }else {
                        res.json({mag: '没有该项数据'})
                    }
                }).catch(err => res.json(err))

}